<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>for循环打印金字塔</title>
    <style>
        td{
            padding: 5px 10px;
            border: 1px #000 solid;
        }
        table{
            border-collapse: collapse;
        }
    </style>
</head>
<body>

<script>
    /*
    //等于1，小于等于5的
    var num = prompt("请输入金字塔层数");
    for (var y = 1;y <= num;y++){
        var a = num - y;
        for (i = 1;i <= a;i++){
            document.write("&nbsp");
        }
        var h = y * 2 -1;
        for (var l = 1;l <= h;l++){
            document.write("*");
        }
        document.write("<br>");
    }
    */

    /*
    //等于0，小于5的
    var num = prompt("请输入金字塔的层数");
    for (var i = 0;i < num;i++){
        var w = num - i;
        for (var a = 0;a < w;a++){
            document.write("&nbsp");
        }
        var v = (i+1)*2-1
        for (var b = 0;b < v;b++){
            document.write("*")
        }
        document.write("<br>");
    }
    */


    /*
    for (var i=0 ; i<1 ; i++){
        console.log(i);
        console.log(i+1);
        console.log("123");

        for(var a=0 ; a<2;a++){
            console.log(a);
            console.log("456");
            for (var x = 0; x <3;x++){
                console.log("789");
                console.log(x+1);
            }
        }
        for (var w = 0;w <2;w++){
            console.log(w-1);
            console.log(w*2);
        }
    }
    */

    /*
    //九九乘法表
    var j = 9;
    for (var i = 1;i <= j;i++){
        for (var a = 1;a <= i;a++){
            document.write("&nbsp");
            var b = i * a;
            document.write(i +"*" + a + "="+b);
        }
        document.write("<br>");
    }
    */

    document.write("<table>");
    for (var i = 1;i <= 9;i++){
        document.write("<tr>");
        for (var j = 1; j <= i;j++){
            document.write("<td>");
            var a = j * i;
            document.write(j + "*" + i + "=" + j*i);
            document.write("</td>");
        }
        document.write("</tr>");
    }
    document.write("</table>");
</script>
</body>
</html>